package com.qf.dao;

import com.qf.pojo.Type;
import com.qf.util.DBUtil;
import org.apache.commons.dbutils.DbUtils;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanHandler;
import org.apache.commons.dbutils.handlers.BeanListHandler;

import java.sql.SQLException;
import java.util.List;

/**
 * @author LiXuekai on 2022/5/24
 */
public class TypeDaoImpl implements TypeDao {
    //创建util工具类
    private   QueryRunner queryRunner=new QueryRunner(DBUtil.getDateSource());


    @Override
    public List<Type> findAll() {
        String sql = "select * from tb_goods_type";
        try {
            List<Type> list = queryRunner.query(sql, new BeanListHandler<Type>(Type.class));
            return list;
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return null;
    }
}